/**********************************************************************************************************************
 *
 * Project:    mGameEngine
 * File:       multiloader.h
 * Author:     karooolek
 * Created on: 2009-03-22
 *
 **********************************************************************************************************************/

#ifndef MULTILOADER_H_
#define MULTILOADER_H_

#include "list.h"
#include "loader.h"

namespace mGameEngine
{

/**
 * Multiple resources loader.
 * Contains sub-loaders and loads them as one big resource.
 * It's responsible for freeing all loaded resources.
 */
class MultiLoader: public Loader
{
protected:
    /**
     * All sub-loaders
     */
    List<Loader *> _loaders;

    /**
     * Active sub-loader
     */
    const Loader *_activeLoader;

public:
    /**
     * Create new empty multi-loader.
     */
    MultiLoader();

    /**
     * Destroy multi-loader.
     * @return
     */
    virtual ~MultiLoader();

    /**
     * Get sub-loaders.
     * @return sub-loaders list
     */
    const List<Loader *> &getLoaders() const
    {
        return _loaders;
    }

    /**
     * Add new sub-loader.
     * @param loader sub-loader
     */
    void addLoader(Loader *loader);

    /**
     * Remove sub-loader.
     * @param loader sub-loader
     */
    void removeLoader(Loader *loader);

    /**
     * Get active sub-loader.
     * @return active sub-loader
     */
    const Loader *getActiveLoader() const
    {
        return _activeLoader;
    }

    /**
     * Load multiple sub-loaders.
     */
    void load();

    /**
     * Unload multiple sub-loaders.
     */
    void unload();
};

}

#endif // MULTILOADER_H_
